package Interceptor;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * Created by Properly on 2018/7/1.
 */
public class CategoryFormValidator extends Validator {
    @Override
    protected void validate(Controller controller) {
        String name = controller.getPara("name");
        if (name.isEmpty()) {
            addError("error", "版块名称不为空");
        }
    }

    @Override
    protected void handleError(Controller controller) {
        controller.renderHtml("名称不能为空" + "<br><a href='/category/list'>返回版块列表</a>");
    }
}
